<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>订单确认</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/count.css">
</head>
<body>
<div class="container">
    <div class="header">
        <h1>订单确认</h1>
        <p>订单号: ${order.id != null ? order.id : '待生成'}</p>
    </div>

    <div class="order-summary">
        <table class="order-items">
            <thead>
            <tr>
                <th>商品图片</th>
                <th>商品名称</th>
                <th>单价</th>
                <th>数量</th>
                <th>小计</th>
            </tr>
            </thead>
            <tbody>
            <c:forEach items="${order.items}" var="item">
                <tr>
                    <td>
                        <img src="data:image/${item.goods.imageType};base64,${item.goods.imageData != null ? item.goods.imageData : ''}"
                             onerror="this.src='${pageContext.request.contextPath}/image/noproduct.png'"
                             alt="${item.goods.name}"
                             class="product-image">
                    </td>
                    <td>${item.goods.name}</td>
                    <td>¥${item.goods.price}</td>
                    <td>${item.quantity}</td>
                    <td>¥${item.subtotal}</td>
                </tr>
            </c:forEach>
            </tbody>
        </table>

        <div class="total-section">
            <p>总计: <strong>¥${order.total}</strong></p>
        </div>
    </div>

    <div class="action-buttons">
        <a href="${pageContext.request.contextPath}/shopListServlet" class="btn btn-secondary">继续购物</a>
        <a href="#" class="btn btn-primary" onclick="submitOrder()">提交订单</a>
    </div>
</div>

<script>
    function submitOrder() {
        // TODO: Implement order submission
        alert('订单提交功能即将上线！');
    }
</script>
</body>
</html>
